﻿using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace CssAndJsCombiner.UI.WebControls
{
    public class Javascript : ClientResourceControl
    {
        protected override string ClientResourceFile
        {
            get { return "js.axd"; }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            string path = AddVersion(Path, ClientResourceType.Js);

            HtmlGenericControl script = new HtmlGenericControl("script");
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", WebContext.ResolveClientUrlAbsolute(path));

            script.RenderControl(writer);
        }
    }
}
